﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ProductIntory.Domains;
using ProductIntory.ErrorCodes;
using ProductIntory.Read.Apis.Application.Command.ProductionStorageCommands;
using ProductIntory.Read.Apis.Application.Command.ProductsCommands;

namespace ProductIntory.Read.Apis.Controllers
{
    [Route("api/[controller]/[action]")]
 
    [ApiController]
    public class ProductionStorageController : ControllerBase
    {
        IMediator mediator;

        public ProductionStorageController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpGet]
        public async Task<ApiPaging<List<ProductionStorage>>> GetProductionStorages([FromQuery]  ShowProductionStorageCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> UpdatProductionStorages(UpdateProductionStorageCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> DelProductionStorages( [FromQuery] DeletProductionStorageCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
